package main.old.old_2022;

/**
 * @Author: Take-off
 * @Description: TODO
 * 746. 使用最小花费爬楼梯
 * 62. 不同路径
 * @Date: 2022/8/1 5:13 PM
 * @Version: 1.0
 **/
public class Solution0728 {

    //使用最小花费爬楼梯
    public int minCostClimbingStairs(int[] cost) {

        int n = cost.length;

        int[] dp = new int[n + 1];
        dp[0] = dp[1] = 0;

        for (int i = 2; i <= n; i++) {
            dp[i] = Math.min(dp[i - 1] + cost[i - 1], dp[i - 2] + cost[i - 2]);
        }
        return dp[n];
    }

    //不同路径
    public int uniquePaths(int m, int n) {
        int[][] f = new int[m][n];
        for (int i = 0; i < m; ++i) {
            f[i][0] = 1;
        }
        for (int j = 0; j < n; ++j) {
            f[0][j] = 1;
        }
        for (int i = 1; i < m; ++i) {
            for (int j = 1; j < n; ++j) {
                f[i][j] = f[i - 1][j] + f[i][j - 1];
            }
        }
        return f[m - 1][n - 1];


    }

}
